// 创建多个promise
const p1 = new Promise((resolve, reject) => {
  setTimeout(() => {
    reject(11111)
  }, 1000)
})

const p2 = new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve(22222)
  }, 2000)
})

const p3 = new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve(33333)
  }, 3000)
})


// allSettled
// 会将所有结果汇总到数组返回
Promise.allSettled([p1, p2, p3]).then(res => {
  console.log(res);
}).catch(err => {
  console.log(err);
})

// function *test() {
//   const p1 = new Promise((resolve, reject) => {
//     setTimeout(() => {
//       reject(11111)
//     }, 1000)
//   })
  
//   const p2 = new Promise((resolve, reject) => {
//     setTimeout(() => {
//       resolve(22222)
//     }, 2000)
//   })
  
//   const p3 = new Promise((resolve, reject) => {
//     setTimeout(() => {
//       resolve(33333)
//     }, 3000)
//   })
  
//   const result = yield Promise.allSettled([p1, p2, p3]);
//   console.log("result", result);
// }
// const a = test();
// console.log(a.next());
// console.log(a.next());
// console.log(a.next());


